package com.share.user.service.impl;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.hutool.system.UserInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.user.api.domain.UpdateUserLogin;
import com.share.user.mapper.UserLoginLogMapper;
import com.share.user.service.IUserInfoService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author HuanghanChi
 * @version 1.0
 * @date 2025/4/11 17:13
 **/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserLoginLogMapper, UserInfo> implements IUserInfoService  {
    @Autowired
    private WxMaService wxMaService;

    @Autowired
    private UserLoginLogMapper userLoginLogMapper;

    @Override
    public Boolean updateUserLogin(UpdateUserLogin updateUserLogin) {
        return false;
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public UserInfo wxLogin(String code) {
        try {
            String openId = null;
            // 获取openId
            WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code);
        } catch (WxErrorException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
}
